﻿using System;

class Node<T>
{
    public T Data { get; set; }
    public Node<T> Next { get; set; }
    public Node(T data) => Data = data;
}

class GenericList<T>
{
    private Node<T> head;

    public void Add(T data)
    {
        var node = new Node<T>(data) { Next = head };
        head = node;
    }

    public void ForEach(Action<T> action)
    {
        Node<T> node = head;
        while (node != null)
        {
            action(node.Data);
            node = node.Next;
        }
    }
}

class Program
{
    static void Main()
    {
        var list = new GenericList<int>();
        list.Add(5);
        list.Add(10);
        list.Add(3);

        int max = int.MinValue, min = int.MaxValue, sum = 0;

        list.ForEach(item =>
        {
            Console.WriteLine(item);
            if (item > max) max = item;
            if (item < min) min = item;
            sum += item;
        });

        Console.WriteLine($"最大值: {max}, 最小值: {min}, 总和: {sum}");
    }
}
